package com.lwy.controller;

import com.github.pagehelper.PageInfo;
import com.lwy.dao.BookUserMapper;
import com.lwy.entity.BookNove;
import com.lwy.entity.BookUser;
import com.lwy.service.impl.BookUserServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//用户controller控制层
@RestController
@RequestMapping("user")
public class BookUserController {

    @Resource
    private BookUserServiceImpl bookUserService;

    @Resource
    private BookUserMapper bookUserMapper;

    @RequestMapping("list")
    public List<BookUser> lsp(){
        return bookUserService.list();
    }

    @RequestMapping("logging")
    public Object save(String username,String password){
        return bookUserService.logging(username,password);
    }

    //    根据id修改
    @RequestMapping("edit")
    public Object edit(BookUser bookUser){
        return bookUserService.updateById(bookUser);
    }
    //根据id查询
    @RequestMapping("findById")
    public BookUser findById(Integer id){
        return bookUserService.getById(id);
    }

    //    获取密码
    @RequestMapping("getPwd")
    public Integer getPwd(String pwd,Integer id){
        return bookUserService.getPassword(pwd,id);
    }

    //    修改密码
    @RequestMapping("updPwd")
    public Object pwd(String password,Integer id){
        return bookUserService.updPwd(password,id);
    }


    @RequestMapping("findByName")
    public PageInfo<BookUser> selectByUserName(String username, Integer pageNum, Integer pageSize){
        return bookUserService.page(username,pageNum,pageSize);
    }
}
